<?php
declare (strict_types=1);

namespace app\adminapi\http\middleware;

use app\adminapi\listener\OperationLog;
use Webman\Http\Request;
use Webman\Http\Response;
use Webman\MiddlewareInterface;

/**
 * 操作日志接口中间件
 * Class LoginMiddleware
 * @package app\adminapi\http\middleware
 */
class OperationLogMiddleware implements  MiddlewareInterface
{

    /**
     * @notes 操作日志
     * @param $request
     * @param \Closure $next
     */
    public function process(Request $request, callable $next): Response
    {
        $response = $next($request);

        // 增加操作日志
        (new OperationLog)->handle($response);

        return $response;
    }

}